<?php  
namespace app\library\validate;
use think\Validate;

/**
 * 用户验证器
 * @package app\admin\validate
 */
class User extends Validate{
    //定义验证规则
    protected $rule = [
        'card_id' 		 => 'require',
        'name'      	 => 'require',
        'mobile'   	 	 => 'requireWith|regex:^1\d{10}',
        'password'     	 => 'require|length:6,50',
        'etime'  		 => 'require',
        'code'           => 'require|captcha',
    ];

    //定义验证提示
    protected $message = [
        'card_id.require'  => '请输入校园卡号',
        'name.require'     => '请输入名称',
        'mobile.require'    => '请输入手机号',
        'mobile.regex'      => '手机号格式不正确',
        'password.require' => '密码不能为空',
        'password.length'  => '密码长度不能小于6,大于50',
        'etime.require'    => '过期时间不能为空',
        'code.require'    => '验证码不能为空',
    ];

    //定义验证场景
    protected $scene = [
        'login' =>    ['card_id' => 'require|token', 'password','code'],
    ];
}
?>